//main.cpp
/********************************************************************************
*																				*
*	Author:			Jared Szechy												*
*	Assignment:		Assignment 4												*
*	Class:			CPS-151														*
*	Instructor:		V. Starkley													*
*	Due Date:		October 3													*
*																				*
*	This program simulates a pez dispenser through the use of stacks.			*
*																				*
********************************************************************************/

#include <iostream>
#include <ctime>
#include <string>
#include "stack.h"
#include "functions.h"

using namespace std;

main()
{
	string select, popped;
	int numCandies, found = 0, count = 0;
	srand(int(time(0)));
	Stack<string> newDisp;
	Stack<string> origDisp;

	//randomly fill the dispenser
	fillDispenser(origDisp);
	
	//get flavor from user
	cout << "Please enter the flavor you wish to eat." << endl
		 << "Your choices are orange, lime, lemon, grape, or cherry." << endl;

	cin >> select;

	//if invalid flavor prompt user and get another selection
	while (select != "orange" && select != "lime" && select != "grape" && select != "cherry" && select != "lemon")
	{
		cout << "Invalid candy selection, please re-enter!" << endl;
		cout << "Selection: ";
		cin >> select;
	}

	//get number of candies from user
	cout << "Please enter the number of " << select << " candies you wish to eat" << endl;
	cin >> numCandies;

	//determine how many of the desired candies are in the dispenser
	found = findItems(origDisp, numCandies, select);

	if (found < numCandies)
		cout << endl << "Sorry, there were only " << found << ' ' << select << " candies in the container." << endl;

	//pop the desired candies from the dispenser
	getCandies(origDisp, newDisp, found, select);

	//print the dispensers to the screen
	printStacks(origDisp, newDisp);

	system("pause");
	return 0;
}
